Skip to content

Conversation

@weidongxu-microsoft
Copy link
Contributor

@weidongxu-microsoft weidongxu-microsoft commented Jan 20, 2026

@microsoft-github-policy-service microsoft-github-policy-service bot added the emitter:client:java Issue for the Java client emitter: @typespec/http-client-java label Jan 20, 2026
@github-actions
Copy link
Contributor

No changes needing a change description found.

@azure-sdk
Copy link
Collaborator

azure-sdk commented Jan 20, 2026

You can try these changes here

🛝 Playground 🌐 Website 🛝 VSCode Extension

@haolingdong-msft
Copy link
Member

could you please show the generated code diff by adding the fix?

@weidongxu-microsoft
Copy link
Contributor Author

could you please show the generated code diff by adding the fix?

I cannot, because without this fix, emitter crashes, and there is no code generated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for array encoding (comma-separated string representation) of closed enum types in the Java HTTP client generator. The change introduces a new ConvertFromJsonTypeTrait interface and updates the deserialization logic to properly handle enum values when deserializing from array-encoded strings.

Changes:

  • Introduced ConvertFromJsonTypeTrait interface for converting JSON wire values back to client types
  • Implemented the new trait on PrimitiveType, ClassType, and EnumType to support bidirectional conversion
  • Fixed array encoding deserialization logic in StreamSerializationModelTemplate to use the new conversion trait instead of relying on defaultValueExpression
  • Added unit tests for both ConvertToJsonTypeTrait and ConvertFromJsonTypeTrait conversion methods

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
ConvertFromJsonTypeTrait.java New interface defining conversion from JSON wire type to client type
ConvertToJsonTypeTrait.java Updated documentation to clarify it converts to JSON wire type
PrimitiveType.java Implements ConvertFromJsonTypeTrait and updates convertToJsonType to properly handle client-to-wire conversion
ClassType.java Implements ConvertFromJsonTypeTrait with explicit handling for various special types like DATE_TIME, DURATION, URL
EnumType.java Implements ConvertFromJsonTypeTrait to support enum deserialization from JSON values
StreamSerializationModelTemplate.java Fixes array encoding deserialization to use ConvertFromJsonTypeTrait instead of defaultValueExpression, with proper error handling
ConvertToJsonTypeTraitTests.java New test file verifying type conversion to JSON representation
ConvertFromJsonTypeTraitTests.java New test file verifying type conversion from JSON representation

weidongxu-microsoft and others added 2 commits January 20, 2026 17:08
…/src/main/java/com/microsoft/typespec/http/client/generator/core/model/clientmodel/ClassType.java

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.

@weidongxu-microsoft weidongxu-microsoft added this pull request to the merge queue Jan 21, 2026
Merged via the queue into microsoft:main with commit 25cd241 Jan 21, 2026
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:java Issue for the Java client emitter: @typespec/http-client-java

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants